﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.Renderer
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using UnityEngine.Bindings;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering;
using UnityEngine.Scripting;
using UnityEngineInternal;

#nullable disable
namespace UnityEngine
{
  /// <summary>
  ///   <para>General functionality for all renderers.</para>
  /// </summary>
  [RequireComponent(typeof (Transform))]
  [NativeHeader("Runtime/Graphics/GraphicsScriptBindings.h")]
  [UsedByNativeCode]
  [NativeHeader("Runtime/Graphics/Renderer.h")]
  public class Renderer : Component
  {
    [Obsolete("Property lightmapTilingOffset has been deprecated. Use lightmapScaleOffset (UnityUpgradable) -> lightmapScaleOffset", true)]
    [EditorBrowsable(EditorBrowsableState.Never)]
    public Vector4 lightmapTilingOffset
    {
      get => Vector4.zero;
      set
      {
      }
    }

    [Obsolete("Use probeAnchor instead (UnityUpgradable) -> probeAnchor", true)]
    [EditorBrowsable(EditorBrowsableState.Never)]
    public Transform lightProbeAnchor
    {
      get => this.probeAnchor;
      set => this.probeAnchor = value;
    }

    [Obsolete("Use shadowCastingMode instead.", false)]
    [EditorBrowsable(EditorBrowsableState.Never)]
    public bool castShadows
    {
      get => this.shadowCastingMode != 0;
      set => this.shadowCastingMode = value ? ShadowCastingMode.On : ShadowCastingMode.Off;
    }

    /// <summary>
    ///   <para>Specifies whether this renderer has a per-object motion vector pass.</para>
    /// </summary>
    [Obsolete("Use motionVectorGenerationMode instead.", false)]
    public bool motionVectors
    {
      get => this.motionVectorGenerationMode == MotionVectorGenerationMode.Object;
      set
      {
        this.motionVectorGenerationMode = value ? MotionVectorGenerationMode.Object : MotionVectorGenerationMode.Camera;
      }
    }

    /// <summary>
    ///   <para>Should light probes be used for this Renderer?</para>
    /// </summary>
    [Obsolete("Use lightProbeUsage instead.", false)]
    public bool useLightProbes
    {
      get => this.lightProbeUsage != 0;
      set => this.lightProbeUsage = value ? LightProbeUsage.BlendProbes : LightProbeUsage.Off;
    }

    /// <summary>
    ///   <para>The bounding box of the renderer in world space.</para>
    /// </summary>
    public Bounds bounds
    {
      [FreeFunction(Name = "RendererScripting::GetWorldBounds", HasExplicitThis = true)] get
      {
        Bounds ret;
        this.get_bounds_Injected(out ret);
        return ret;
      }
      [NativeName("SetWorldAABB")] set => this.set_bounds_Injected(ref value);
    }

    /// <summary>
    ///   <para>The bounding box of the renderer in local space.</para>
    /// </summary>
    public Bounds localBounds
    {
      [FreeFunction(Name = "RendererScripting::GetLocalBounds", HasExplicitThis = true)] get
      {
        Bounds ret;
        this.get_localBounds_Injected(out ret);
        return ret;
      }
      [NativeName("SetLocalAABB")] set => this.set_localBounds_Injected(ref value);
    }

    /// <summary>
    ///   <para>Reset custom world space bounds.</para>
    /// </summary>
    [NativeName("ResetWorldAABB")]
    [MethodImpl(MethodImplOptions.InternalCall)]
    public extern void ResetBounds();

    /// <summary>
    ///   <para>Reset custom local space bounds.</para>
    /// </summary>
    [NativeName("ResetLocalAABB")]
    [MethodImpl(MethodImplOptions.InternalCall)]
    public extern void ResetLocalBounds();

    [FreeFunction(Name = "RendererScripting::SetStaticLightmapST", HasExplicitThis = true)]
    private void SetStaticLightmapST(Vector4 st) => this.SetStaticLightmapST_Injected(ref st);

    [FreeFunction(Name = "RendererScripting::GetMaterial", HasExplicitThis = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern Material GetMaterial();

    [FreeFunction(Name = "RendererScripting::GetSharedMaterial", HasExplicitThis = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern Material GetSharedMaterial();

    [FreeFunction(Name = "RendererScripting::SetMaterial", HasExplicitThis = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern void SetMaterial(Material m);

    [FreeFunction(Name = "RendererScripting::GetMaterialArray", HasExplicitThis = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern Material[] GetMaterialArray();

    [FreeFunction(Name = "RendererScripting::GetMaterialArray", HasExplicitThis = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern void CopyMaterialArray([Out] Material[] m);

    [FreeFunction(Name = "RendererScripting::GetSharedMaterialArray", HasExplicitThis = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern void CopySharedMaterialArray([Out] Material[] m);

    [FreeFunction(Name = "RendererScripting::SetMaterialArray", HasExplicitThis = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern void SetMaterialArray([NotNull("ArgumentNullException")] Material[] m);

    [FreeFunction(Name = "RendererScripting::SetPropertyBlock", HasExplicitThis = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    internal extern void Internal_SetPropertyBlock(MaterialPropertyBlock properties);

    [FreeFunction(Name = "RendererScripting::GetPropertyBlock", HasExplicitThis = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    internal extern void Internal_GetPropertyBlock([NotNull("ArgumentNullException")] MaterialPropertyBlock dest);

    [FreeFunction(Name = "RendererScripting::SetPropertyBlockMaterialIndex", HasExplicitThis = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    internal extern void Internal_SetPropertyBlockMaterialIndex(
      MaterialPropertyBlock properties,
      int materialIndex);

    [FreeFunction(Name = "RendererScripting::GetPropertyBlockMaterialIndex", HasExplicitThis = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    internal extern void Internal_GetPropertyBlockMaterialIndex(
      [NotNull("ArgumentNullException")] MaterialPropertyBlock dest,
      int materialIndex);

    /// <summary>
    ///   <para>Returns true if the Renderer has a material property block attached via SetPropertyBlock.</para>
    /// </summary>
    [FreeFunction(Name = "RendererScripting::HasPropertyBlock", HasExplicitThis = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    public extern bool HasPropertyBlock();

    /// <summary>
    ///   <para>Lets you set or clear per-renderer or per-material parameter overrides.</para>
    /// </summary>
    /// <param name="properties">Property block with values you want to override.</param>
    /// <param name="materialIndex">The index of the Material you want to override the parameters of. The index ranges from 0 to Renderer.sharedMaterials.Length-1.</param>
    public void SetPropertyBlock(MaterialPropertyBlock properties)
    {
      this.Internal_SetPropertyBlock(properties);
    }

    /// <summary>
    ///   <para>Lets you set or clear per-renderer or per-material parameter overrides.</para>
    /// </summary>
    /// <param name="properties">Property block with values you want to override.</param>
    /// <param name="materialIndex">The index of the Material you want to override the parameters of. The index ranges from 0 to Renderer.sharedMaterials.Length-1.</param>
    public void SetPropertyBlock(MaterialPropertyBlock properties, int materialIndex)
    {
      this.Internal_SetPropertyBlockMaterialIndex(properties, materialIndex);
    }

    /// <summary>
    ///   <para>Get per-Renderer or per-Material property block.</para>
    /// </summary>
    /// <param name="properties">Material parameters to retrieve.</param>
    /// <param name="materialIndex">The index of the Material you want to get overridden parameters from. The index ranges from 0 to Renderer.sharedMaterials.Length-1.</param>
    public void GetPropertyBlock(MaterialPropertyBlock properties)
    {
      this.Internal_GetPropertyBlock(properties);
    }

    /// <summary>
    ///   <para>Get per-Renderer or per-Material property block.</para>
    /// </summary>
    /// <param name="properties">Material parameters to retrieve.</param>
    /// <param name="materialIndex">The index of the Material you want to get overridden parameters from. The index ranges from 0 to Renderer.sharedMaterials.Length-1.</param>
    public void GetPropertyBlock(MaterialPropertyBlock properties, int materialIndex)
    {
      this.Internal_GetPropertyBlockMaterialIndex(properties, materialIndex);
    }

    [FreeFunction(Name = "RendererScripting::GetClosestReflectionProbes", HasExplicitThis = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern void GetClosestReflectionProbesInternal(object result);

    /// <summary>
    ///   <para>Makes the rendered 3D object visible if enabled.</para>
    /// </summary>
    public extern bool enabled { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    /// <summary>
    ///   <para>Is this renderer visible in any camera? (Read Only)</para>
    /// </summary>
    public extern bool isVisible { [NativeName("IsVisibleInScene"), MethodImpl(MethodImplOptions.InternalCall)] get; }

    /// <summary>
    ///   <para>Does this object cast shadows?</para>
    /// </summary>
    public extern ShadowCastingMode shadowCastingMode { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    /// <summary>
    ///   <para>Does this object receive shadows?</para>
    /// </summary>
    public extern bool receiveShadows { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    /// <summary>
    ///   <para>Allows turning off rendering for a specific component.</para>
    /// </summary>
    public extern bool forceRenderingOff { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    [NativeName("GetIsStaticShadowCaster")]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern bool GetIsStaticShadowCaster();

    [NativeName("SetIsStaticShadowCaster")]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern void SetIsStaticShadowCaster(bool value);

    /// <summary>
    ///   <para>Is this renderer a static shadow caster?</para>
    /// </summary>
    public bool staticShadowCaster
    {
      get => this.GetIsStaticShadowCaster();
      set => this.SetIsStaticShadowCaster(value);
    }

    /// <summary>
    ///   <para>Specifies the mode for motion vector rendering.</para>
    /// </summary>
    public extern MotionVectorGenerationMode motionVectorGenerationMode { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    /// <summary>
    ///   <para>The light probe interpolation type.</para>
    /// </summary>
    public extern LightProbeUsage lightProbeUsage { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    /// <summary>
    ///   <para>Should reflection probes be used for this Renderer?</para>
    /// </summary>
    public extern ReflectionProbeUsage reflectionProbeUsage { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    /// <summary>
    ///   <para>Determines which light layer this renderer lives on, if you use a.</para>
    /// </summary>
    public extern uint renderingLayerMask { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    /// <summary>
    ///   <para>This value sorts renderers by priority. Lower values are rendered first and higher values are rendered last.</para>
    /// </summary>
    public extern int rendererPriority { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    /// <summary>
    ///   <para>Describes how this renderer is updated for ray tracing.</para>
    /// </summary>
    public extern RayTracingMode rayTracingMode { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    /// <summary>
    ///   <para>Name of the Renderer's sorting layer.</para>
    /// </summary>
    public extern string sortingLayerName { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    /// <summary>
    ///   <para>Unique ID of the Renderer's sorting layer.</para>
    /// </summary>
    public extern int sortingLayerID { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    /// <summary>
    ///   <para>Renderer's order within a sorting layer.</para>
    /// </summary>
    public extern int sortingOrder { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    internal extern int sortingGroupID { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    internal extern int sortingGroupOrder { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    internal extern byte stagePriority { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    /// <summary>
    ///   <para>Controls if dynamic occlusion culling should be performed for this renderer.</para>
    /// </summary>
    [NativeProperty("IsDynamicOccludee")]
    public extern bool allowOcclusionWhenDynamic { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    [NativeProperty("StaticBatchRoot")]
    internal extern Transform staticBatchRootTransform { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    internal extern int staticBatchIndex { [MethodImpl(MethodImplOptions.InternalCall)] get; }

    [MethodImpl(MethodImplOptions.InternalCall)]
    internal extern void SetStaticBatchInfo(int firstSubMesh, int subMeshCount);

    /// <summary>
    ///   <para>Indicates whether the renderer is part of a with other renderers.</para>
    /// </summary>
    public extern bool isPartOfStaticBatch { [NativeName("IsPartOfStaticBatch"), MethodImpl(MethodImplOptions.InternalCall)] get; }

    /// <summary>
    ///   <para>Matrix that transforms a point from world space into local space (Read Only).</para>
    /// </summary>
    public Matrix4x4 worldToLocalMatrix
    {
      get
      {
        Matrix4x4 ret;
        this.get_worldToLocalMatrix_Injected(out ret);
        return ret;
      }
    }

    /// <summary>
    ///   <para>Matrix that transforms a point from local space into world space (Read Only).</para>
    /// </summary>
    public Matrix4x4 localToWorldMatrix
    {
      get
      {
        Matrix4x4 ret;
        this.get_localToWorldMatrix_Injected(out ret);
        return ret;
      }
    }

    /// <summary>
    ///   <para>If set, the Renderer will use the Light Probe Proxy Volume component attached to the source GameObject.</para>
    /// </summary>
    public extern GameObject lightProbeProxyVolumeOverride { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    /// <summary>
    ///   <para>If set, Renderer will use this Transform's position to find the light or reflection probe.</para>
    /// </summary>
    public extern Transform probeAnchor { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    [NativeName("GetLightmapIndexInt")]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern int GetLightmapIndex(LightmapType lt);

    [NativeName("SetLightmapIndexInt")]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern void SetLightmapIndex(int index, LightmapType lt);

    [NativeName("GetLightmapST")]
    private Vector4 GetLightmapST(LightmapType lt)
    {
      Vector4 ret;
      this.GetLightmapST_Injected(lt, out ret);
      return ret;
    }

    [NativeName("SetLightmapST")]
    private void SetLightmapST(Vector4 st, LightmapType lt)
    {
      this.SetLightmapST_Injected(ref st, lt);
    }

    /// <summary>
    ///   <para>The index of the baked lightmap applied to this renderer.</para>
    /// </summary>
    public int lightmapIndex
    {
      get => this.GetLightmapIndex(LightmapType.StaticLightmap);
      set => this.SetLightmapIndex(value, LightmapType.StaticLightmap);
    }

    /// <summary>
    ///   <para>The index of the real-time lightmap applied to this renderer.</para>
    /// </summary>
    public int realtimeLightmapIndex
    {
      get => this.GetLightmapIndex(LightmapType.DynamicLightmap);
      set => this.SetLightmapIndex(value, LightmapType.DynamicLightmap);
    }

    /// <summary>
    ///   <para>The UV scale &amp; offset used for a lightmap.</para>
    /// </summary>
    public Vector4 lightmapScaleOffset
    {
      get => this.GetLightmapST(LightmapType.StaticLightmap);
      set => this.SetStaticLightmapST(value);
    }

    /// <summary>
    ///   <para>The UV scale &amp; offset used for a real-time lightmap.</para>
    /// </summary>
    public Vector4 realtimeLightmapScaleOffset
    {
      get => this.GetLightmapST(LightmapType.DynamicLightmap);
      set => this.SetLightmapST(value, LightmapType.DynamicLightmap);
    }

    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern int GetMaterialCount();

    [NativeName("GetMaterialArray")]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern Material[] GetSharedMaterialArray();

    [MethodImpl(MethodImplOptions.InternalCall)]
    internal extern bool IsPersistent();

    /// <summary>
    ///   <para>Returns all the instantiated materials of this object.</para>
    /// </summary>
    public Material[] materials
    {
      get
      {
        if (!this.IsPersistent())
          return this.GetMaterialArray();
        Debug.LogError((object) "Not allowed to access Renderer.materials on prefab object. Use Renderer.sharedMaterials instead", (Object) this);
        return (Material[]) null;
      }
      set => this.SetMaterialArray(value);
    }

    /// <summary>
    ///   <para>Returns the first instantiated Material assigned to the renderer.</para>
    /// </summary>
    public Material material
    {
      get
      {
        if (!this.IsPersistent())
          return this.GetMaterial();
        Debug.LogError((object) "Not allowed to access Renderer.material on prefab object. Use Renderer.sharedMaterial instead", (Object) this);
        return (Material) null;
      }
      set => this.SetMaterial(value);
    }

    /// <summary>
    ///   <para>The shared material of this object.</para>
    /// </summary>
    public Material sharedMaterial
    {
      get => this.GetSharedMaterial();
      set => this.SetMaterial(value);
    }

    /// <summary>
    ///   <para>All the shared materials of this object.</para>
    /// </summary>
    public Material[] sharedMaterials
    {
      get => this.GetSharedMaterialArray();
      set => this.SetMaterialArray(value);
    }

    public void GetMaterials(List<Material> m)
    {
      if (m == null)
        throw new ArgumentNullException("The result material list cannot be null.", nameof (m));
      if (this.IsPersistent())
        throw new InvalidOperationException("Not allowed to access Renderer.materials on prefab object. Use Renderer.sharedMaterials instead");
      NoAllocHelpers.EnsureListElemCount<Material>(m, this.GetMaterialCount());
      this.CopyMaterialArray(NoAllocHelpers.ExtractArrayFromListT<Material>(m));
    }

    public void GetSharedMaterials(List<Material> m)
    {
      if (m == null)
        throw new ArgumentNullException("The result material list cannot be null.", nameof (m));
      NoAllocHelpers.EnsureListElemCount<Material>(m, this.GetMaterialCount());
      this.CopySharedMaterialArray(NoAllocHelpers.ExtractArrayFromListT<Material>(m));
    }

    public void GetClosestReflectionProbes(List<ReflectionProbeBlendInfo> result)
    {
      this.GetClosestReflectionProbesInternal((object) result);
    }

    [SpecialName]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern void get_bounds_Injected(out Bounds ret);

    [SpecialName]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern void set_bounds_Injected(ref Bounds value);

    [SpecialName]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern void get_localBounds_Injected(out Bounds ret);

    [SpecialName]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern void set_localBounds_Injected(ref Bounds value);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern void SetStaticLightmapST_Injected(ref Vector4 st);

    [SpecialName]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern void get_worldToLocalMatrix_Injected(out Matrix4x4 ret);

    [SpecialName]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern void get_localToWorldMatrix_Injected(out Matrix4x4 ret);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern void GetLightmapST_Injected(LightmapType lt, out Vector4 ret);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern void SetLightmapST_Injected(ref Vector4 st, LightmapType lt);
  }
}
